package com.mz.ozy.activity.me;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.mz.ozy.R;
import com.mz.ozy.base.BaseActivity;
import com.mz.ozy.bean.FriendBean;
import com.mz.ozy.bean.MyBounsBean;
import com.mz.ozy.bean.MyBounsRecodeBean;
import com.mz.ozy.bean.NewBonusBean;
import com.mz.ozy.bean.NewBonusDetailBean;
import com.mz.ozy.bean.NewBonusDonateBean;
import com.mz.ozy.bean.NewGQBean;
import com.mz.ozy.bean.NewResponeBean;
import com.mz.ozy.bean.PronotionBean;
import com.mz.ozy.mvp.presenter.MyBounsPresenter;
import com.mz.ozy.mvp.view.MyBonusContract;
import com.mz.ozy.utils.Utils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author liucan on 2020/4/1 0001.
 */
public class ServiceOutletsActivity extends BaseActivity<MyBonusContract.View, MyBounsPresenter> implements MyBonusContract.View {


    @BindView(R.id.ll_top)
    LinearLayout llTop;
    @BindView(R.id.tv_balance)
    TextView tvBalance;
    @BindView(R.id.tv_lj_score)
    TextView tvLjScore;
    @BindView(R.id.tv_grade)
    TextView tvGrade;
    //    @BindView(R.id.tv_jxs)
//    TextView tvJxs;
//    @BindView(R.id.tv_fu)
//    TextView tvFu;
    @BindView(R.id.tv_tj)
    TextView tvTj;
    @BindView(R.id.tv_small_team)
    TextView tvSmallTeam;
    @BindView(R.id.tv_health_speak)
    TextView tvHealthSpeak;
    @BindView(R.id.tv_team_bv)
    TextView tvTeamBv;
    @BindView(R.id.tv_last_month)
    TextView tvLastMonth;
    @BindView(R.id.tv_wait_money)
    TextView tvWaitMoney;
    @BindView(R.id.tv_wait_score)
    TextView tvWaitScore;
    @BindView(R.id.tv_now_grade)
    TextView tvNowGrade;
    @BindView(R.id.tv_wait_money_now)
    TextView tvWaitMoneyNow;
    @BindView(R.id.tv_wait_score_now)
    TextView tvWaitScoreNow;
    @BindView(R.id.ll_root)
    LinearLayout llRoot;
    private PronotionBean dataItem;
    private MyBounsBean mBonusBean;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_service_outlets);
        ButterKnife.bind(this);
        initTitle2();
        llRoot.setBackgroundColor(0);
        llTop.setBackgroundColor(0);
        tvCenterTitle.setText("服务网点");
        tvBack.setImageResource(R.mipmap.white_back);
        tvCenterTitle.setTextColor(getResources().getColor(R.color.white));
//        rightTextView.setTextSize(10);
//        rightTextView.setGravity(Gravity.CENTER);
//        rightTextView.setTextColor(getResources().getColor(R.color.white));
//        rightTextView.setVisibility(View.VISIBLE);
//        rightTextView.setText("奖励明细");
//        rightTextView.setBackgroundResource(R.drawable.round_89c03b);
//        rightTextView.setHeight(65);
//        rightTextView.setWidth(160);
        rightTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(ServiceOutletsActivity.this, MyBonusDetailActivity.class));
            }
        });

//        mPresenter.vipUpSh(this, 1);
    }

    @Override
    protected void onResume() {
        super.onResume();
        mPresenter.info(this, 1);
        mPresenter.vipUpDataSh(this, "", 1);
    }

    @Override
    public void getInfoSuccess(MyBounsBean bean) {
        mBonusBean = bean;
        tvBalance.setText(Utils.decimalUtils(bean.getTotal_bonus(), 2));
        String grade_state = "";
        switch (bean.getGrade_state()) {
            case 0:
                grade_state = "在职";
                break;
            case 1:
                grade_state = "休职";
                break;
            case 2:
                grade_state = "停职";
                break;
            case 3:
                grade_state = "离职";
                break;
        }
        tvTj.setText(bean.getZtnum() + "");
        tvHealthSpeak.setText(bean.getOne_seven_num() + "");
        tvTeamBv.setText(Utils.decimalUtils(bean.getTotal_bv(), 2));
        if (bean.getState().equals("0")) {
            tvLastMonth.setText("待发放");
        } else {
            tvLastMonth.setText("已发放");
        }
//        if (bean.getDistributor() == 0) {
//            tvJxs.setVisibility(View.GONE);
//        }
//        if (bean.getServies_dot() == 0) {
//            tvFu.setVisibility(View.GONE);
//        }
//        switch (bean.getNowgrade()) {
//            case 1:
//                tvGrade.setText("一级经销商");
//                break;
//            case 2:
//                tvGrade.setText("二级经销商");
//                break;
//            case 3:
//                tvGrade.setText("三级经销商");
//                break;
//            case 4:
//                tvGrade.setText("四级经销商");
//                break;
//            case 5:
//                tvGrade.setText("五级经销商");
//                break;
//        }

        switch (bean.getServies_dot()) {
            case 1:
                tvGrade.setText("社区服务网点");
                break;
            case 2:
                tvGrade.setText("区级服务网点");
                break;
            case 3:
                tvGrade.setText("市级服务网点");
                break;
            case 4:
                tvGrade.setText("地区级服务网点");
                break;
        }
        tvLjScore.setText(Utils.decimalUtils(bean.getTotal_integral(), 2));
        tvWaitMoney.setText(Utils.decimalUtils(bean.getBonus_profit(), 2));
        tvWaitScore.setText(Utils.decimalUtils(bean.getIntegral_profit(), 2));
        //  tvWaitMoneyNow.setText(bean.getTwo_four_num() + "");
        tvSmallTeam.setText(bean.getTwo_four_num() + "");
    }

    @OnClick({R.id.tv_level_up, R.id.tv_bonus_detail})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_level_up:
                if (mBonusBean != null || dataItem != null) {
                    if (mBonusBean.getServies_dot() == 0 || dataItem.getPromotion_map().getState() == 4) {
                        UpdataActivity.go(this, dataItem.getPromotion_map().getId(), 1, true);
                    } else if (dataItem.getPromotion_map().getState() == 2) {
                        PromotionTypeActivity.go(this, 1);
                    } else if (dataItem.getPromotion_map().getState() == 1 && dataItem.getIfup() == 1) {
                        UpdataActivity.go(this, dataItem.getPromotion_map().getId(), 1, true);
                    } else {
                        PromotionTypeActivity.go(this, 1);
                    }
                }
                break;
            case R.id.tv_bonus_detail:
                MyBonusDetailActivity.go(this, 1);
                break;
        }
    }

    @Override
    public void getInfoRecode(MyBounsRecodeBean bean) {

    }

    @Override
    public void getVipUpShSuccess(FriendBean bean) {
    }

    @Override
    public void getVipUpDataInfoSuccess(PronotionBean bean) {
        dataItem = bean;
    }

    @Override
    public void newBonusSuccess(NewBonusBean bean) {

    }

    @Override
    public void newBonusDetailSuccess(NewBonusDetailBean bean) {

    }

    @Override
    public void newBonusDonateSuccess(NewBonusDonateBean bean) {

    }

    @Override
    public void newGQSuccess(NewGQBean bean) {

    }
}
